% Example,
% Read two greyscale images of Lena
Imoving=imread('images/lenag1.png'); 
Istatic=imread('images/lenag4.png');

% Register the images
[Ireg,Bx,By,Fx,Fy] = register_images(Imoving,Istatic,struct('Similarity','p','Registration','affine'));

% Show the registration result
figure,
imshow(Ireg);
figure,
subplot(2,2,1), imshow(Imoving); title('moving image');
subplot(2,2,2), imshow(Istatic); title('static image');
subplot(2,2,3), imshow(Ireg); title('registerd moving image');
% Show also the static image transformed to the moving image
Ireg2=movepixels(Istatic,Fx,Fy);
subplot(2,2,4), imshow(Ireg2); title('registerd static image');

% Show the transformation fields
figure,
subplot(2,2,1), imshow(Bx,[]); title('Backward Transf. in x direction');
subplot(2,2,2), imshow(Fx,[]); title('Forward Transf. in x direction');
subplot(2,2,3), imshow(By,[]); title('Backward Transf. in y direction');
subplot(2,2,4), imshow(Fy,[]); title('Forward Transf. in y direction');

% Calculate strain tensors
E = strain(Fx,Fy);
% Show the strain tensors
figure,
subplot(2,2,1), imshow(E(:,:,1,1),[]); title('Strain Tensors Exx');
subplot(2,2,2), imshow(E(:,:,1,2),[]); title('Strain Tensors Exy');
subplot(2,2,3), imshow(E(:,:,2,1),[]); title('Strain Tensors Eyx');
subplot(2,2,4), imshow(E(:,:,2,2),[]); title('Strain Tensors Eyy');